import React, { Component } from 'react'
import HeaderNav from '../../components/nav'
import { Route } from 'react-router-dom'

import MenuComponent from '../../components/menu'
import HomePage from '../home/home'
import VidesPage from '../video/video'
import NowDataPage from '../now-data/now-data'
import HistoryDataPage from '../history-data/history-data'
import ErrorPage from '../error/error'
import ReportPage from '../report/report'

import AccountPassword from '../setting/account'
import UserSetting from '../setting/user'
import PermissionSetting from '../setting/permission'
import MenuSetting from '../setting/menu'
import ErrorSetting from '../setting/errorSetting'
import RolePage from '../setting/role'
import { getToken } from '../../utils/tools'
import DeviceList from '../device/devide-list'
import DeviceChild from '../device/device-child'
import DeviceSignal from '../device/device-signal'
import DeviceTagPage from '../device/device-tag'

class DzMain extends Component {
    state = {

    }

    constructor(props) {
        super(props)
        const token = getToken();
        window.router = this.props.history
        if (!token) {
            this.props.history.replace('/login')
        } else {
            // this.props.history.replace('/main/home')
        }
        console.log(this.props.history)
    }

    render() {
        return (
            <div>
                <HeaderNav />
                <div className="dz-main d-flex">
                    <MenuComponent></MenuComponent>
                    <div className="dz-content">
                        <Route path='/main/home' component={HomePage} />
                        <Route path='/main/video' component={VidesPage} />
                        <Route path='/main/now-data' component={NowDataPage} />
                        <Route path='/main/history-data' component={HistoryDataPage} />
                        <Route path='/main/error' component={ErrorPage} />
                        <Route path='/main/report' component={ReportPage} />
                        <Route path='/main/password' component={AccountPassword} />
                        <Route path='/main/user' component={UserSetting} />
                        <Route path='/main/permis' component={PermissionSetting} />
                        <Route path='/main/menu' component={MenuSetting} />
                        <Route path='/main/error-setting' component={ErrorSetting} />
                        <Route path='/main/role' component={RolePage} />
                        <Route path='/main/device' component={DeviceList} />
                        <Route path='/main/device-child' component={DeviceChild} />
                        <Route path='/main/device-signal' component={DeviceSignal} />
                        <Route path='/main/device-tag' component={DeviceTagPage} />
                    </div>
                </div>
            </div>
        );
    }
}

export default DzMain